package ltd.newbee.mall.controller.admin;


import ltd.newbee.mall.service.impl.SaleServiceImpl;
import ltd.newbee.mall.util.Result;
import ltd.newbee.mall.util.ResultGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.Year;


@RestController
@RequestMapping("/admin")
public class SaleController {

    @Autowired
    SaleServiceImpl saleService;

    @RequestMapping("sale/day")
    public Result day(Integer day) {
        return ResultGenerator.genSuccessResult(saleService.select_Nearly_10_days(day));

    }

    @RequestMapping("sale/year")
    public Result month(String year) {
        return ResultGenerator.genSuccessResult(saleService.select_Month_by_Year(year));
    }

    @RequestMapping("sale/rate")
    public Result rate(Integer rate) {
        return ResultGenerator.genSuccessResult(saleService.selectRate(rate));
    }

}
